<?php

namespace app\controller\admin\cnf;

use app\bll\SyscnfUcenter as BllSyscnfUcenter;
use app\bll\SyscnfUpload as BllSyscnfUpload;
use app\bll\SyscnfSafe as BllSyscnfSafe;
use core\controller\AdminBase;
use Exception;
use support\View;

class Syscnf extends AdminBase
{
    public function index()
    {
        $bllSyscnfUpload = new BllSyscnfUpload();
        $uploadcnf       = $bllSyscnfUpload->find();

        $bllSyscnfUcenter = new BllSyscnfUcenter();
        $ucentercnf       = $bllSyscnfUcenter->find();

        $BllSyscnfSafe = new BllSyscnfSafe();
        $savecnf       = $BllSyscnfSafe->find();

        View::assign('uploadcnf', $uploadcnf);
        View::assign('ucentercnf', $ucentercnf);
        View::assign('savecnf', $savecnf);
        return $this->view();
    }

    public function setUpload()
    {

        if (is_post()) {
            try {
                $bllSyscnfUpload = new BllSyscnfUpload();
                $bllSyscnfUpload->save(request()->post());
            } catch (Exception $ex) {
                return $this->error($ex->getMessage());
            }
            return $this->success();
        }
    }

    public function setUcenter()
    {
        if (is_post()) {
            try {
                $bllSyscnfUcenter = new BllSyscnfUcenter();
                $bllSyscnfUcenter->save(request()->post());
            } catch (Exception $ex) {
                return $this->error($ex->getMessage());
            }
            return $this->success();
        }
    }


    public function setSave()
    {
        if (is_post()) {
            try {
                $BllSyscnfSafe = new BllSyscnfSafe();
                $BllSyscnfSafe->save(request()->post());
            } catch (Exception $ex) {
                return $this->error($ex->getMessage());
            }
            return $this->success();
        }
    }
}
